<?PHP
	include("Json_class.php");
	
  //use latest minorRev 14
  $url  ='http://api.ean.com/ean-services/rs/hotel/v3/list?minorRev=5';
  $url .= '&apiKey=ukd47n3sahbbvpu247dknv5r';
  $url .= '&cid=55505';
  $url .= '&locale=en_US&city=Dallas&stateProvinceCode=TX&countryCode=US&numberOfResults=4';
  $url .= '&searchRadius=50';
	//using the cache returns results much faster
  $url .= '&supplierCacheTolerance=MED_ENHANCED';
	//dates and occupancy
  $url .='&arrivalDate=10/20/2012&departureDate=10/23/2012&room1=2';
  $url .='&_type=json';
  
  $header[] = "Accept: application/json";
  $header[] = "Accept-Encoding: gzip";
  
  $ch = curl_init();
  
  curl_setopt( $ch, CURLOPT_HTTPHEADER, $header );
  curl_setopt($ch,CURLOPT_ENCODING , "gzip");
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  curl_setopt( $ch, CURLOPT_URL, $url );
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  $response = json_decode(curl_exec($ch));
  ?>
  <html>
  <head>
	
  </head>
  <style>
	*{ margin:0px; padding: 0px; }
	#header{
	  	background-color: #00ff00;
	  	height: 100px;
	  	width: 100%;
	}
	#page{
		background-color: #c0c0c0;
	  	margin: 0 auto;
	  	width: 100%;
	}
	
	#page #content{
		background-color: #800080;
		heigth: auto;
		margin: 0 auto;
		width: 1200px;
	}
	#page #content #search-widget{
		background-color: #808000;
		display: inline-block;
		width: 500px;
		height: auto;
		float: left;
		margin-left: 15px;
		margin-right: 20px;
	}
	#page #content #destination-list{
		background-color: #008080;
		display: inline-block;
		width: 650px;
		//float: left;
	}	
	#footer{
		width: 100%;
		height: 200px;
		background-color: #000080;
	}
	  
	#hotel-content{
	  	margin:0 auto;
	  	width: 70%;
	  	color:red;
	}
  </style>
  <body>
  	<div id="header">
  		<img src="" />
  	</div>
  	<div id="page">
  		<div id="content"> 
	  		<div id="search-widget">
	  			<input type="textbox" />
	  			<br />
	  			<input type="textbox" />
	  			<input type="textbox" />
	  			<div class="ui-widget">
		 			<label for="autocomplete">Hotel Name: </label>
		 			<input id="autocomplete" />
  				</div>
	  		</div>
	  		<div id="destination-list">
				<?PHP
			    //print_r($url);
			    print_r("<BR>");
			    print_r("<pre>");
				
				$jsonObject= new Json($response);
				$hotelList = $jsonObject->GetHotelList();
				$hotelNumber = count($hotelList);
				print_r("Nr hotele: ".$hotelNumber);
				echo ">>".$hotelList[0]->GetLocationDescription();
				echo "<br>";
				print_r("<div id='hotel-content'>");
				for($i=0; $i<$hotelNumber ; $i++)
				{
					print_r("<span>");
					print_r($hotelList[$i]->GetLocationDescription().PHP_EOL);
					print_r("</span>");
					print_r("<img src='http://images.travelnow.com/".$hotelList[$i]->GetThumbnailUrl()."' \>");
				}
				print_r("</div>");	
				//$jsonObject->GetJsonRawData();
			 	print_r("</pre>");
			    ?>
	   		</div>
	   	</div>
	</div>
	<div id="footer">
	</div>
  </body>
</html>